<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class MenuComponent extends Menu {
    
    public static function getMenuList(&$array_menus = array(), $filter = array()) {
        
        $menus = MenuComponent::model()->findAllByAttributes(array('id_parent'=>$filter['parent_id'], 'type'=>$filter['type']));
        
        foreach($menus as $menu) {
            $menu_array = array();
            $menu_array['ID'] = $menu->id;
            $menu_array['NAME'] = StringUtils::getI18n($menu->name, Yii::app()->language);
            $menu_array['POSITION'] = $menu->position;
            $menu_array['LINK'] = $menu->link;
            $menu_array['SECTION'] = $menu->section;
            $menu_array['ID_PARENT'] = $menu->id_parent;
            $menu_array['ALLOW_ACCESS'] = explode(",", $menu->group_id);
            
            if ($menu->id_parent == 0) {
                $array_menus[$menu->id]['parent'] = $menu_array;
            } else {
                $array_menus[$menu->id]['child'] = $menu_array;
            }
            $filter['parent_id'] = $menu->id;
            self::getMenuList($array_menus[$menu->id]['childs'], $filter);
		}
    }
}
?>
